package hnlg.com.cn.purviewmanage.modulemanage.control;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import hnlg.com.cn.common.RespBean;
import hnlg.com.cn.model.ModuleVO;
import hnlg.com.cn.purviewmanage.modulemanage.service.IModuleService;

@RestController
@RequestMapping("/ModuleManageControl")
public class ModuleManageControl {
List<ModuleVO> list=null;
RespBean rb=null;
ModuleVO vo=null;
@Resource IModuleService ModuleService;
//http://localhost:8044/test/ModuleManageControl/queryList?modulename=合同管理&url=hetong.html
@RequestMapping("/queryList")
public List<ModuleVO> queryList(
@RequestParam("modulename") String modulename,
@RequestParam("url") String url){
	try{
	  ModuleVO vo=new ModuleVO();	
	vo.setModulename(modulename);vo.setUrl(url);
	list=ModuleService.queryList(vo);
	}catch(Exception e){
		e.printStackTrace();
	}
	return list;
}
	
@RequestMapping("/queryvo")
public ModuleVO queryvo(
@RequestParam("moduleid")String moduleid){
	try{
	System.out.println("moduleid="+moduleid);
	vo=ModuleService.queryvo(moduleid);
	}catch(Exception e){
		e.printStackTrace();
	}
	return vo;
}

@RequestMapping("/addModule")
public RespBean addModule(ModuleVO vo){
	try{
	ModuleService.addModule(vo);
	rb=new RespBean("msg", "添加成功");
	}catch(Exception e){
		rb=new RespBean("msg", "添加失败");
		e.printStackTrace();
	}
	return rb;
}

@RequestMapping("/updateModule")
public RespBean updateModule(ModuleVO vo){
	try{
		System.out.println("id="+vo.getModuleid());
		boolean flag=ModuleService.updateModule(vo);
		System.out.println(flag);
		rb=new RespBean("msg", "更新成功");
	}catch(Exception e){
		rb=new RespBean("msg", "更新失败");
		e.printStackTrace();
	}
	return rb;
}

@RequestMapping("/deleteModule")
public RespBean deleteModule(
@RequestParam("moduleid") String moduleid){
	try{
		System.out.println("moduleid="+moduleid);
		ModuleService.deleteModule(moduleid);
		rb=new RespBean("msg", "删除成功");
		
	}catch(Exception e){
		rb=new RespBean("msg", "删除失败");
		e.printStackTrace();
	}
	return rb;
}
}
